var app = getApp();
Page({
  data: {
    nickName: '默认用户',
    avatarUrl:'https://cake.cindata.cn/assets/defaultAvater-088a81f8333264b791ec89edd25ee72e.png',
    phoneNumber: '17710060120',
  },
  onLoad: function (options) {
    var _this = this
    wx.request({
      url: 'https://cake.cindata.cn/user/getUserInfo',
      data: {
      },
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      complete: function complete(res) {
        if (res.statusCode == 200) {
          console.log(res.data);
          _this.setData({
            phoneNumber: res.data.cellphone
          })
        } else {
          console.log("请求收货地址失败，请稍后重试！");
        }
      }
    });

    var fullName = app.globalData.nickName
    if (fullName) {
      this.setData({
        nickName: app.globalData.nickName
      })
    }
    var avatarUrl = app.globalData.avatarUrl
    if (avatarUrl) {
      this.setData({
        avatarUrl: app.globalData.avatarUrl
      })
    }
  },
  gotoOrder: function () {
    wx.navigateTo({
      url: '/pages/order/order'
    });
  },
  gotoMyaddress: function () {
    wx.navigateTo({
      url: '/pages/myAddress/myAddress'
    });
  },
  makePhoneCall: function () {
    wx.makePhoneCall({
      phoneNumber: this.data.phoneNumber
    })
  },
  editInfo: function () {
    console.log("sssssssssssssssssss");
    wx.navigateTo({
      url: '/pages/user/user'
    });
  }
});